package com.sptus.web.controller.admin;

import com.sptus.common.core.controller.BaseController;
import com.sptus.common.core.domain.AjaxResult;
import com.sptus.system.service.IWorkOrdersService;
import com.sptus.web.util.YearlyDateGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/sys/deviceAlarm")
@Api(tags="设备告警管理")
public class DeviceAlarm  extends BaseController {

    @Autowired
    private IWorkOrdersService workOrdersService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping("getAlarmClassify")
    @ApiOperation("获取设备告警分类")
    public AjaxResult getAlarmClassify() {
        HashMap<String, Object> list= workOrdersService.getAlarmClassify();
        return AjaxResult.success(list);
    }

    @GetMapping("getAlarmGradeNum")
    @ApiOperation("获取设备告警数量")
    public AjaxResult getAlarmGradeNum() {
        HashMap<String, Object> list= new HashMap<String,Object>();
        list.put("Major","10");
        list.put("General","15");
        list.put("Warning","7");
        list.put("Reminder","6");
        list.put("Attention","3");
        return AjaxResult.success(list);
    }

    @GetMapping("getAlarmEveryDayNum")
    @ApiOperation("获取设备告警每日数量")
    public AjaxResult getAlarmEverydayNum(Integer year) {
        List<YearlyDateGenerator.DailyData> dailyData = YearlyDateGenerator.generateYearlyData(year);
        return AjaxResult.success(dailyData);
    }
}
